<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/Java1812WebTest1/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
</head>
<body>
	<div class = "container">
	<a class="btn btn-success" href ="${pageContext.request.contextPath}/addstudent.jsp" >添加</a>
	欢迎回来<span>${user.name}</span>
	<a href="${pageContext.request.contextPath}/logOut">注销</a>
	<a href="${pageContext.request.contextPath}/online_user_list.jsp">在线用户列表</a>
		<table class="table table-striped table-bordered table-hover table-condensed">
			<tr>
				<td>编号</td>
				<td>姓名</td>
				<td>年龄</td>
				<td>性别</td>
				<td>删除</td>
				<td>修改</td>
			</tr>
			<c:forEach items="${pageBean.list}" var="student">
				<tr>
					<td>${student.id}</td>
					<td>${student.name}</td>
					<td>${student.age}</td>
					<td>${student.gender}</td>
					<td><a href="javascript:void(0)" onclick="deleteById(${student.id})">删除</a></td>
					<td><a href="${pageContext.request.contextPath}/student?method=toUpdate&id=${student.id}">修改</a></td>
				</tr>
			</c:forEach>
		</table>
		<nav aria-label="Page navigation">
		  <ul class="pagination">
		    <c:if test="${pageBean.pageNo ==1 }">
		    	<li class="disabled">
			      <a href="#" aria-label="Previous">
			        <span aria-hidden="true">&laquo;</span>
			      </a>
		    	</li>
		    </c:if>
		    <c:if test="${pageBean.pageNo != 1}">
		    	<li>
			      <a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${pageBean.pageNo-1}&pageSizer=3" aria-label="Previous">
			        <span aria-hidden="true">&laquo;</span>
			      </a>
		    	</li>
		    </c:if>
		    <c:forEach begin="1" end="${pageBean.totalPage}" var="i">
		    	<c:if test="${i==pageBean.pageNo}"> 
		    		<li class="active"><a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${i}&pageSize=3">${i}</a></li>
		    	</c:if>
		    	<c:if test="${i!=pageBean.pageNo}">
		    		<li><a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${i}&pageSize=3">${i}</a></li>
		    	</c:if>
		    </c:forEach>
		    
		    <c:if test="${pageBean.pageNo == pageBean.totalPage}">
			    <li class="disabled">
			      <a href="#" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
		    </c:if>
		    <c:if test="${pageBean.pageNo != pageBean.totalPage}">
		    	<li>
			      <a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${pageBean.pageNo+1}&pageSize=3" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
		    </c:if>
		  </ul>
		</nav>
	<script type="text/javascript">
		function deleteById(id){
			var isDel = confirm("是否删除呢？");
			if(isDel){
				location.href="${pageContext.request.contextPath}/student?method=deleteStudent&id="+id;
			}
		}
	</script>
	</div>
</body>
</html>